<template>
	<view class="page-box">
		<view class="page-tag">项目名称</view>
		<view class="page-title">
			<view class="title-text">{{projectName}}</view>
		</view>
		<view class="page-tag">更新时间</view>
		<view class="page-title" >
			<view class="title-text border-sty" @click="showSinglePicker">{{showTime}}</view>
		</view>
		<view class="page-tag">更新内容</view>

		<view class="text-content" v-for="item,index in pageData.LIST">
			<view class="title-text">
				{{item.GROUP_NAME}} > {{item.TAB_NAME}}
			</view>
			<view class="page-form">
				<view v-if="item.FIELDS.length>0" class="form-item" v-for="ites in item.FIELDS">
					<view class="uni-title uni-common-pl">{{ites.FIELD_NAME}}</view>
					<view class="uni-textarea" v-if="ites.ISFILE==='Y'">
						<view class="style-text filestyle" v-for="ttes in ites.FILES" @tap="openFile" :data-url="ttes.URL" >
							{{ttes.FILENAME}}	
						</view>
					</view>
					<view class="uni-textarea" v-else>
						<view class="style-text">
							{{ites.FIELD_DATA}}	
						</view>
					</view>
				</view>
				<view v-if="item.TABLES.length>0" class="item-form" v-for="ites in item.TABLES">
					<view class="item-box" v-for="itemtab in ites.TABLE_DATA">
						<view class="item-title-box"  v-for="itemData,index in itemtab" :key='index'>
							<view class="item-title">{{ites.TABLE_HEADER[index].TITLE}}</view>
							<!-- <view class="item-content">{{itemData.FIELD_DATA}}</view> -->
							<view class="item-content" v-if="itemData.ISFILE==='Y'">
								<view class="style-text filestyle" v-for="ttes in itemData.FILES" @tap="openFile" :data-url="ttes.URL" >
									{{ttes.FILENAME}}	
								</view>
							</view>
							<view class="item-content" v-else>
								<view class="style-text">
									{{itemData.FIELD_DATA}}	
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<mpvue-picker :themeColor="themeColor" ref="mpvuePicker1" :mode="mode" :deepLength="deepLength" :pickerValueDefault="pickerValueDefault"
		@onConfirm="onConfirm1" @onCancel="onCancel" :pickerValueArray="pickerValueArray"></mpvue-picker>
	</view>
</template>

<script>
	import mpvuePicker from '@/components/mpvue-picker/mpvuePicker.vue';
	export default {
		components: {
		    mpvuePicker
		},
		data() {
			return {
				themeColor: '#007AFF',
				mode: '',
				deepLength: 1,
				pickerValueDefault: [3],
				pickerValueArray:[],
				dataKey:'',
				projId:'',
				projectName:'',
				pageData:{},
				timeList:{},
				showTime:'',
				sendTimeCode:''
			}
		},
		methods: {
			async getData(code){
				let data={}
				if(code){
					data={
						projId:this.dataKey,
						version	: this.sendTimeCode
					}
				}else{
					data={
						projId:this.dataKey
					}
				}
				uni.showLoading({
				
				})
				
				const res = await this.$req({
					url:'bus/proj/modify.do',
					data:data
				})
				uni.hideLoading()
				if(res.data.success){
					this.pageData=res.data.attributes
					this.timeList=res.data.attributes.VERSION_LIST
					if(res.data.attributes.VERSION_LIST&&res.data.attributes.VERSION_LIST.length){
						this.showTime=res.data.attributes.VERSION_LIST[0].CODE_NAME
					}
					console.log(this.pageData,"res的职位")
				}else{
					uni.showToast({
						title:res.data.messages[0].content,
						icon:'none'
					})
				}
			},
			onConfirm1(e) {
				console.log(e.value[0])
				this.showTime= e.label
			    this.sendTimeCode= e.value[0]
				this.getData(this.sendTimeCode)
			},
			onCancel(e) {
			    console.log(e)
			},
			//下载
			openFile(e) {
				const url = e.currentTarget.dataset.url
				this.$util.openFile(url)
			},
			showSinglePicker(){
				let dataArry=[]
				this.pickerValueArray=[]
				if(this.timeList&&this.timeList.length){
					dataArry=this.timeList
					this.$refs.mpvuePicker1.show()
				}
				
				dataArry.map(item=>{
					this.pickerValueArray.push(
						{
							label: item.CODE_NAME,
							value: item.CODE
						}
					)
				})
				this.mode = 'selector'
				this.deepLength = 1
				this.pickerValueDefault = [0]
				
			}
			
		},
		onLoad(options){
			this.dataKey = options.dataKey;
			this.projId=options.projId;
			this.projectName=options.projectName;
			this.getData()
		
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #e9f0f2;
	}
	.page-box{
		margin: 20rpx 30rpx;
		padding: 38rpx 30rpx;
		width: 690rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		
		.title-text{
			margin: 20rpx 0;
			font-size: 28rpx;
			color: #337ab7;
		}
		.border-sty{
			width: 100%;
			height: 42rpx;
			font-weight: 500;
			text-align: center;
			border: 1px solid #666666;
			border-radius: 8rpx;
		}
		.page-title{
			margin: 20rpx 0;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.title-history{
				
				font-size: 28rpx;
				color: #0086B3;
			}
			.title-icon{
				display: flex;
				align-items: center;
				image{
					width: 27rpx;
					height: 27rpx;
					margin-right: 10rpx;
				}
				.icon-right{
					font-size: 24rpx;
					line-height: 34rpx;
					color: #0099cc;
				}
			}
		}
		.page-tag{
			// width: 120rpx;
			height: 42rpx;
			margin-top: 14rpx;
			font-size: 26rpx;
			line-height: 42rpx;
			text-align: center;
			background-color: #00ac0c;
			border-radius: 4rpx;
			color: #FFFFFF;
		}
		.text-content{
			padding: 20rpx;
			background-color: #f6f6f6;
			border-radius: 6rpx;
			margin-top: 40rpx;
		}
		.page-form{
			margin-top: 32rpx;
			// padding: 0 40rpx;
			
			
			.item-form{
				.item-box{
					width: 590rpx;
					display: flex;
					flex-direction: column;
					border-radius: 4rpx;
					background-color: #fefefe;
					margin-bottom: 20rpx;
					padding: 20rpx 10rpx;
					color: #808080;
					.item-title-box{
						display: flex;
						flex-direction: row;
						font-size: 26rpx;
						.item-title{
							width: 130rpx;
							margin-right:20rpx ;
						}
						.item-content{
							flex: 1;
							.filestyle{
								color: #0099cc;
							}
						}
					}
				}
			}
			
			.form-item{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				// margin-bottom: 30rpx;
				min-height: 108rpx;
			
				
				.uni-title{
					width: 130rpx;
					font-size: 26rpx;
					margin-right:20rpx ;
					color: #414a5d;
				}
				.uni-textarea{
					width: 460rpx !important;
					font-size: 26rpx;
					line-height: 36rpx;
					// border-bottom: 2rpx solid #dce4e6;
					color: #808080;
					/deep/.uni-textarea-wrapper{
						width: 430rpx !important;
					}
					.line-style{
						width: 100%;
						height: 16rpx;
						border-bottom: 2rpx solid #dce4e6;
					}
				}
				.style-text{
					width: 460rpx !important;
					font-size: 26rpx;
					line-height: 34rpx;
				}
				.filestyle{
					color: #0099cc;
				}
			}
		}
		
	}
</style>
